5-E
Simple site for the info you need...
  • Add Local Admin
  • Backup Dogecoin Wallet
  • Batch Start Powershell
  • Copy A File(s) To All Users On A PC
  • CPU Load Test
  • Disable Users
  • Email Group Members
  • Email With Powershell
  • Exchange Total Size
  • Export to XLSX
  • Export User Cert
  • Get System Info
  • Import Active Directory Module
  • Last Login For All Computer
  • Last Login For All Users
  • Last Login For Select Users
  • List Domain controllers
  • List Groups (With Count) In Active Directory To TXT
  • List Groups (With Count) In Active Directory To XLSX
  • List Groups For A User(s)
  • List Groups In Active Directory to TXT
  • List Home Directory
  • List Members In A Group(s)
  • Password Generator
  • Ping Test
  • Printer Reset
  • Run A Process Every Few Minutes
  • Search For Files On All Local Drives
  • Show iSCSI Device And Disk Number
  • Uninstall Java

Get Groups For A User(s)

This is one of the first powershell scripts I built and it show it LOL. Maybe one day I will update it but for now it works..

Ok, so this script pulls in users from the input file and exports the user and the groups they are a member of to a TXT file.
CODE:
$names = "input.txt" 
Import-Module ActiveDirectory 
$objInputFileContent = get-content $strInputFileName 
foreach ($name in $names) { 
write-output $name >>members.txt 
write-output `r`n  >>members.txt 
$((Get-ADUser -Identity $name -Properties *).MemberOf -split (",")  | Select-String -SimpleMatch "CN=") -replace "CN=","" >>members.txt 
write-output .......  >>members.txt 
write-output `r`n  >>members.txt 
write-output `r`n  >>members.txt 
} 
Use at your own risk
Input File:
UserName
SamAccount
Use at your own risk
Download: List Groups For A User(s).zip

Tag(s): Powershell


Could you spare a few coins?
Dogecoin - D838u1m9YRdzVVu8CZ1JsR78WHgQmUZSr8
Bitcoin - 13iKLoPXcWEYcGtqCi4UcjGQEs7r6M6LFc
Thank you
  • Home

  • Batch
  • Email
  • Exchange
  • How To
  • Local PC
  • Powershell
  • Security